

import java.io.File;
import java.io.PrintWriter;

import javax.swing.SwingUtilities;

import motifs.ImageATraiter;

public class Runner {

	public static String IN_PATH = "src/IMAGES/";
	public static String OUT_PATH = "src/RESULTATS/";


	public static void main(String [] args){
		final long time = System.currentTimeMillis();
		SwingUtilities.invokeLater(new Runnable(){
			public void run(){
				String [] s = new File(IN_PATH).list();
				try{
					int copetur = 0;
					PrintWriter pw = new PrintWriter("MCGG_8_4_16.csv");
					PrintWriter HW = new PrintWriter("Histograms.csv");
					System.out.println("debug1");
					for(int i =0; i< s.length; i++){
						if(s[i].toLowerCase().endsWith(".jpeg") ||
								s[i].toLowerCase().endsWith(".png") || 
								s[i].toLowerCase().endsWith(".gif") || 
								s[i].toLowerCase().endsWith(".jpg") ||
								s[i].toLowerCase().endsWith(".bmp")){	
							ImageATraiter img = new ImageATraiter(IN_PATH,OUT_PATH,s[i], 4, ImageATraiter.EIGHT_DIR_ANGLES, ImageATraiter.EIGHT_DIR_SIZE);
							//System.out.println(IN_PATH+s[i]);
							//System.out.println(img.toString());
							for(int ppp = 0 ; ppp < img.getLesEmpruntes().size(); ppp++){
								img.getLesEmpruntes().get(ppp).saveJPEG(OUT_PATH+s[i]+ppp+".jpg");
							}
							copetur = copetur + img.getLesEmpruntes().size();
							HW.println(img.getLinearHistograms());
							HW.flush();
							pw.println(img.toString());
							pw.flush();

						}
					}	
					HW.close();
					pw.close();
					
					
					System.out.println("nombre d'empreintes :" + copetur);
					long end  = System.currentTimeMillis();

					System.out.println("temps d'execution : "+((float)(end-time))/1000f);
					System.out.println("Fin du programme");
				}catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
}
